package java03;

import java.util.*;
abstract class Shape{
	double PI = 3.14;
	protected abstract double getArea();
	protected abstract double getPerimeter();
}
class Rectangle extends Shape{
	private int width;
	private int length;
	public Rectangle() {
		super();
	}
	public Rectangle(int width, int length) {
		this.width = width;
		this.length = length;
	}
	public double getPerimeter(){
		return (double)2*(width+length);
	}
	public double getArea(){
		return (double)width*length;
	}
	public String toString() {
		return "Rectangle [width=" + width + ", length=" + length + "]";
	}
}

class Circle extends Shape{
	private int radius;
	public Circle() {
		super();
	}
	public Circle(int radius) {
		this.radius = radius;
	}
	public double getPerimeter(){
		return (2*PI*radius);
	}
	public double getArea(){
		return (PI*radius*radius);
	}
	public String toString() {
		return "Circle [radius=" + radius + "]";
	}
}

public class Java33 {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		Shape[] arr = new Shape[n];
		for(int i = 0;i < n; i++){
			String str = new String(in.nextLine());
			if(str.equals("rect"))
				arr[i] = new Rectangle(in.nextInt(),in.nextInt());
			if(str.equals("cir"))
				arr[i] = new Circle(in.nextInt());
			String b = new String(in.nextLine());
		}
		System.out.println(sumAllPerimeter(arr));
		System.out.println(sumAllArea(arr));
		System.out.println(Arrays.deepToString(arr));
		for (int i = 0; i < arr.length; i++) {
			System.out.println(arr[i].getClass()+","+arr[i].getClass().getSuperclass());
		}
	}
	public static double sumAllArea(Shape[] arr){
		
		double sum = 0;
		for(Shape e:arr){
			sum += e.getArea();
		}
		return sum;
	}
	public static double sumAllPerimeter(Shape[] arr){
		double sum = 0;
		for(Shape e:arr){
			sum += e.getPerimeter();
		}
		return sum;
	}
}